package test_model_base;

import junit.framework.TestCase;

import org.junit.After;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;

import com.servlet.model.base.Area;

public class AreaTest extends TestCase {
	private Area area;
	
	@Before
	public void setUp() throws Exception {
		super.setUp();
		area = new Area(91400, "france", "orsay");
	}

	@After
	public void tearDown() throws Exception {
		this.area = null;
	}

	@Test
	public void testArea() {
		area = new Area();
		Assert.assertEquals(0, area.getCity_code());
		Assert.assertNull(area.getCity());
		Assert.assertNull(area.getCountry());
	}

	@Test
	public void testAreaIntStringString() {
		area = new Area(91119, "chine", "gif");
		Assert.assertEquals(91119, area.getCity_code());
		Assert.assertEquals("gif", area.getCity());
		Assert.assertEquals("chine", area.getCountry());
	}

	@Test
	public void testAreaArea() {
		Area a = new Area(91119, "chine", "gif");
		area = new Area(a);
		Assert.assertEquals(91119, area.getCity_code());
		Assert.assertEquals("gif", area.getCity());
		Assert.assertEquals("chine", area.getCountry());
	}

	@Test
	public void testGetCity_code() {
		Assert.assertEquals( 91400, area.getCity_code());
	}

	@Test
	public void testGetHCode() {
		Assert.assertEquals(("91400franceorsay").hashCode(), area.getHCode());
	}

	@Test
	public void testGetCity() {
		Assert.assertEquals("orsay", area.getCity());
	}

	@Test
	public void testGetCountry() {
		Assert.assertEquals("france", area.getCountry());
	}

	@Test
	public void testSetCity_code() {
		area.setCity_code(91119);
		Assert.assertEquals( 91119, area.getCity_code());
	}

	@Test
	public void testSetCity() {
		area.setCity("gif");
		Assert.assertEquals("gif", area.getCity());
	}

	@Test
	public void testSetCountry() {
		area.setCountry("chine");
		Assert.assertEquals("chine", area.getCountry());
	}

	@Test
	public void testGenerateInsertSQL() {
		Assert.assertEquals("INSERT INTO area VALUES (" + ("91400franceorsay").hashCode() + " ,'91400' ,'france' ,'orsay')", area.generateInsertSQL());
	}

}
